/********************************************************/
/*	Author:		gong_libin			*/
/*	Date:		2017_11_01			*/
/*	File:		CmLogger.h			*/
/********************************************************/

#ifndef	_CMLOGGER_H
#define	_CMLOGGER_H

#include "CmAdxDef.h"
#include <json/json.h>
#include <uuid/uuid.h>

class CCmLogger
{
public:
	CCmLogger() {}
	CCmLogger(CMADXINFO_S* pstInfo) {
		m_stLog.m_CMsgId = CmLoggerUuid();
		m_stLog.m_ulMsgTim = CmLoggerMillisecond();
		//m_stLog.m_uiMsgType = 2000:normal request, 2001:dsp request, 2002:response, 2003:imp, 2004:click
		m_stLog.m_CDid = pstInfo->m_CDid;
		m_stLog.m_CAid = pstInfo->m_CAid;
		m_stLog.m_CEid = pstInfo->m_CEid;
		m_stLog.m_CCid = pstInfo->m_CCid;
		m_stLog.m_CIP = pstInfo->m_CIP;
		m_stLog.m_CUa = pstInfo->m_CUa;
		m_stLog.m_CUid = pstInfo->m_CUid;
		m_stLog.m_CImei = pstInfo->m_CImei;
		m_stLog.m_CAdvId = pstInfo->m_CAdvId;
		m_stLog.m_CCrtId = pstInfo->m_CCrtId;
		m_stLog.m_uiAdvType = atoi(pstInfo->m_CType.c_str());
		m_stLog.m_uiAdvSource = pstInfo->m_uiDsp;
		m_stLog.m_uiAdvPrice = pstInfo->m_uiMaxPrice;
		m_stLog.m_CAdCtxtId = pstInfo->m_CCtxtid;
		//m_stLog.m_uiAdvResCode = 1000:normal, 1001:bid success, 2000:failure
		m_stLog.m_uiAdvBidMeth = 2;
	}
	virtual ~CCmLogger() {}

	CMSTR_C CmLoggerSerialize();
	void CmLoggerSetDspId(UINT uiDsp);
	void CmLoggerSetMsgType(UINT uiType);
	void CmLoggerSetResCode(UINT uiCode);

protected:
	CMADXLOG_S	m_stLog;

private:
	CMSTR_C CmLoggerUuid();
	ULONG CmLoggerMillisecond();

};

#endif /* _CMLOGGER_H */
